package com.itheima.controller;

import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    //报错是正常的，编译时idea无法识别服务是否在spring容器里
    @Autowired
    private UserService userService;

    @GetMapping("/{id}")
    public User findById(@PathVariable(name = "id") Integer id) {
        System.out.println("服务端口18083");
        return userService.findById(id);
    }
}
